﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using SubSonic;

namespace SurveyHost.Core.DAL
{
    public partial class HostConfigurationController
    {
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public HostConfiguration FetchConfiguration()
        {
            return ActiveRecord<HostConfiguration>.FetchByID(HttpContext.Current.Request.Url.Host);
        }

        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public void UpdateConfiguration(HostConfiguration config)
        {
            if (config == null) return;
            Update(
                HttpContext.Current.Request.Url.Host,
                config.SurveyName,
                config.AdministratorName,
                config.InvitationEmail,
                config.CompletionEmail,
                config.AdministratorPublicEmail,
                config.AdministratorPrivateEmail,
                config.ScreenApplicant,
                config.SMTPHost,
                config.SMTPPort,
                config.SMTPLoginName,
                config.SMTPLoginPassword,
                config.SMTPUseSSL
                );
        }
    }
}
